package com.xyht.sca_s.student_manage_system.modules.clockIn.controller;


import com.xyht.sca_s.student_manage_system.auth.util.JwtTokenUtil;
import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.clockIn.entity.req.*;
import com.xyht.sca_s.student_manage_system.modules.clockIn.service.SmsClockInGroupSettingService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 考勤组设置表 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2023-08-03
 */
@RestController
@RequestMapping("/clockIn")
@SecretBody
public class SmsClockInGroupSettingController {

    @Resource
    private JwtTokenUtil jwtTokenUtil;
    @Resource
    private SmsClockInGroupSettingService clockInGroupSettingService;

    @ApiModelProperty("设置考勤组-添加考勤的人")
    @PostMapping("/addObjectId")
    public ResponseResult addObjectId(@RequestBody SmsClockInObjectIdAddReq addReq){
        return clockInGroupSettingService.addObjectId(addReq);
    }

    @ApiModelProperty("考勤组设置")
    @PostMapping("/groupSetting")
    public ResponseResult addClockInGroupSetting(HttpServletRequest request, @RequestBody SmsClockInGroupSettingAddReq addReq){
        String userId = jwtTokenUtil.getUserIdByRequest(request);
        return clockInGroupSettingService.addClockInGroupSetting(userId,addReq);
    }

    @ApiModelProperty("查看考勤组列表")
    @GetMapping("/getGroupList")
    public ResponseResult getGroupList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                       @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize){
        return clockInGroupSettingService.getGroupList(pageNum,pageSize);
    }

    @ApiModelProperty("查看考勤组设置")
    @GetMapping("/getGroupSettingDetail")
    public ResponseResult getGroupSettingDetail(HttpServletRequest request, @RequestParam(value = "clockInGroupId",required = false) String clockInGroupId){
        String userId = jwtTokenUtil.getUserIdByRequest(request);
        return clockInGroupSettingService.getGroupSettingDetail(userId,clockInGroupId);
    }

    @ApiModelProperty("修改考勤组设置")
    @PostMapping("/updateGroupSetting")
    public ResponseResult updateGroupSetting(HttpServletRequest request, @RequestBody SmsClockInGroupSettingUpdateReq groupSettingUpdateReq){
        String userId = jwtTokenUtil.getUserIdByRequest(request);
        return clockInGroupSettingService.updateGroupSetting(userId,groupSettingUpdateReq);
    }

    @ApiModelProperty("删除考勤组")
    @PostMapping("/deletedClockInGroup")
    public ResponseResult deletedClockInGroup(@RequestBody SmsClockInGroupSettingDeletedReq deletedReq){
        return clockInGroupSettingService.deletedClockInGroup(deletedReq);
    }

    @ApiModelProperty("查看单个班次组设置")
    @GetMapping("/getClassesSettingId")
    public ResponseResult getClassesSettingId(@RequestParam(value = "classesId",required = false) String classesId,
                                              @RequestParam(value = "clockInGroupId",required = false) String clockInGroupId){
        return clockInGroupSettingService.getClassesSettingId(classesId,clockInGroupId);
    }

    @ApiModelProperty("修改单个班次组设置")
    @PostMapping("/updateClassesSetting")
    public ResponseResult updateClassesSetting(@RequestBody SmsClockInClassesSettingUpdateReq classesUpdateReq){
        return clockInGroupSettingService.updateClassesSetting(classesUpdateReq);
    }

    @ApiModelProperty("查看单个GPS设置")
    @GetMapping("/getGpsSettingId")
    public ResponseResult getGpsSettingId(@RequestParam(value = "gpsId",required = false) String gpsId,
                                          @RequestParam(value = "clockInGroupId",required = false) String clockInGroupId){
        return clockInGroupSettingService.getGpsSettingId(gpsId,clockInGroupId);
    }

    @ApiModelProperty("修改单个GPS设置")
    @PostMapping("/updateGpsSettingId")
    public ResponseResult updateGpsSettingId(@RequestBody SmsClockInGpsSettingUpdateReq gpsSettingUpdateReq){
        return clockInGroupSettingService.updateGpsSettingId(gpsSettingUpdateReq);
    }

    @ApiModelProperty("删除单个GPS")
    @PostMapping("/deletedGps")
    public ResponseResult deletedGps(@RequestBody SmsClockInGpsSettingDeletedReq deletedReq){
        return clockInGroupSettingService.deletedGps(deletedReq);
    }

    @ApiModelProperty("启用")
    @PostMapping("/use")
    public ResponseResult useGroupSetting(@RequestBody SmsClockInGroupSettingDeletedReq useGroupSettingId){
        return clockInGroupSettingService.useGroupSetting(useGroupSettingId);
    }

}

